package com.example.rocketmq_demo.controller.testController;


import lombok.SneakyThrows;
import org.apache.rocketmq.client.producer.DefaultMQProducer;
import org.apache.rocketmq.client.producer.SendResult;
import org.apache.rocketmq.common.message.Message;
import org.apache.rocketmq.spring.core.RocketMQTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;


import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author xyh
 * 2021/8/26
 */
@RestController
public class testController {

    private final RocketMQTemplate rocketMQTemplate;

    public testController(RocketMQTemplate rocketMQTemplate) {
        this.rocketMQTemplate = rocketMQTemplate;
    }

    @RequestMapping("/pushMessage")
    public String get(String id) {
        rocketMQTemplate.convertAndSend("first-topic","你好,Java旅途" + id);
        return id;
    }
    }

